// 注释为笔者添加

var users = [{
    name: "受害者1号",
    phone: "1xxxxxxxxxx",
    pass: "password1",
    type: "管理员"
}, {
    name: "受害者2号",
    phone: "1xxxxxxxxxx",
    pass: "password2",
    type: "xx分管"
}, {
    name: "受害者3号",
    phone: "1xxxxxxxxxx",
    pass: "password3",
    type: "职工"
}, {
    name: "受害者4号",
    phone: "1xxxxxxxxxx",
    pass: "password4",
    type: "职工"
} 
    // 省略若干受害者数据...
];


// 获取input输入的用户名和密码
var phoneNumber = $('#phoneNumberInput').val();
var password = $('#pwdInput').val();


// 查询数据库。。。（离线版）
function queryDatabase(phone, pass) {
    // 用户名和密码完全匹配
    const user = users.find(u => u.phone === phone && u.pass === pass);
    return user;
}


// 调用查询函数并输出结果
var result = queryDatabase(phoneNumber, password);

if (result.length != 0) {
    // 哭死，他甚至还专门加了个管理员的判断
    alert(result.type == "管理员" ? "欢迎回来，" + result.name : "登录成功！");
    document.cookie = "login=true;name=" + result.name + ";type=" + result.type;
    location.href="MAIN.DOMAIN/dashboard"
} else {
    alert("手机号或密码错误！\n请重新输入！");
    $('#phoneNumberInput').val('');
    $('#pwdInput').val('');
}